package com.alibaba.mapper;

import com.alibaba.bean.*;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

@Mapper
@Repository
public interface PerListMapper {

    @Select(value = "select forum.forumId,forum.content,forum.likeNum,forum.replyNum,forum.imgList from forum where forum.userId=#{userId} order by forum.forumId DESC limit #{notelow},#{notehigh}")
    List<PerListData> noteNew(int userId, int notelow, int notehigh);

    @Select(value = "select f.imgList from forum f where f.forumId=#{forumId}")
    String img(int forumId);

    @Select(value = "select u.username,u.avatar,u.userId from user u where u.userId=#{userId}")
    PerInfo info(int userId);

    @Select(value = "select replycontent.userId,user.username,replycontent.touserId,replycontent.content from replycontent left join user on user.userId=replycontent.userId where replycontent.forumId=#{forumId} and replycontent.touserId is not null limit #{notelow},#{notehigh}")
    List<PerReplyListData> noteReply(int forumId, int notelow, int notehigh);

    @Select(value = "select u.username from user u where u.userId=#{touserId}")
    String rName(int touserId);

    //@Select(value = "select user.username from user left join follow on user.userId=follow.followId left join forum on forum.userId=follow.followId left join replycontent on replycontent.touserId=forum.userId where forum.userId=#{userId} limit #{notelow},#{notehigh}")
    //String[] toReplyName(@Param("userId") int userId, int notelow, int notehigh);

}
